package com.yzkj.framework.beans.result;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

@Data
public class PageResponse<T> {

    private int current;

    private int limit;

    private int total;

    private List<T> records;

    public PageResponse(PageParams<T> pageParams, int total, List<T> records) {
        this.current = pageParams.getPage();
        this.limit = pageParams.getLimit();
        this.total = total;
        this.records = records;
    }

    public PageResponse(List<T> records) {
        this.records = records;
    }

    public PageResponse(Page<T> page) {
        this.current = (int) page.getCurrent();
        this.limit = (int) page.getSize();
        this.total = (int) page.getTotal();
        this.records = page.getRecords();
    }

    public PageResponse(PageResponse page, List<T> records) {
        this.current = page.getCurrent();
        this.limit = page.getLimit();
        this.total = page.getTotal();
        this.records = records;
    }
}
